package org.roulette.strategy;

import java.util.List;
import org.roulette.core.Bet;
import org.roulette.utils.BetConstant;
import org.roulette.utils.RouletteType;

/**
 *
 * @author Alpha
 */
public class LastSequenceStrategy implements BetStrategy{
	private static int SEQUENCE_LENGTH = 7;
	List<Bet> betHistory;
	List<Integer> wheelHistory;

	public BetProposal getNextBet(RouletteType type) {
		BetProposal result;
		if(betHistory.size() < SEQUENCE_LENGTH)
			result = getObserveProposal();
		else
			result = getProposal();
		if(result.getAmount() > 18000)
			System.out.println("warning - amount: "+result.getAmount());
		return result;
	}

	public boolean isNextBet() {
		return true;
	}

	public void setHistoryBets(List<Bet> betHistory) {
		this.betHistory = betHistory;
	}

	public void setWheelHistory(List<Integer> wheelHistory) {
		this.wheelHistory = wheelHistory;
	}

	private BetProposal getObserveProposal(){
		return new BetProposal(100, BetConstant.none);
	}

	private BetProposal getProposal(){
		int number = wheelHistory.get(wheelHistory.size() - SEQUENCE_LENGTH);
		BetConstant constant = null;
		if(BetConstant.black.getNumbers().contains(number))
			constant = BetConstant.black;
		else
			constant = BetConstant.red;
		int betAmount = 0;
		Bet lastBet = betHistory.get(betHistory.size()-1);
		if(!lastBet.isLoss())
			betAmount = 100;
		else
			betAmount = lastBet.getBetAmount()*2;
		return new BetProposal(betAmount, constant);
	}
 }
